-
Notifications
You must be signed in to change notification settings - Fork 1k
feat(mysql): support ZEROFILL column attribute #6400
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
|
Fixes #6399 |
0d7321a to
cd8b35c
Compare
sqlglot/dialects/mysql.py
Outdated
| class ZeroFill(exp.Expression): | ||
| pass | ||
|
|
||
|
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We shouldn't define new expression types outside of expressions.py. Please move this to said module and define it as ZeroFillColumnConstraint(ColumnConstraint): arg_types = {}, instead.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
aha ok. i will do it later.
sqlglot/dialects/mysql.py
Outdated
| exp.Year: _remove_ts_or_ds_to_date(), | ||
| exp.UtcTimestamp: rename_func("UTC_TIMESTAMP"), | ||
| exp.UtcTime: rename_func("UTC_TIME"), | ||
| ZeroFill: lambda self, e: "ZEROFILL", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The generation for ZeroFill needs to be moved to the base Generator class, otherwise doing sql() on a MySQL AST will raise, if it contains a ZEROFILL constraint.
This fixes parsing errors encountered when processing legacy MySQL schemas containing numeric columns with the zerofill property.
georgesittas
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Perfect, thank you for the swift iterations!
This fixes parsing errors encountered when processing legacy MySQL schemas containing numeric columns with the zerofill property.
_parse_typesinMySQL.Parserto consume theZEROFILLtoken and store it in the DataType expression.datatype_sqlinMySQL.Generatorto outputZEROFILLwhen the attribute is present.This fixes parsing errors encountered when processing legacy MySQL schemas containing numeric columns with the zerofill property.